package com.example.myannotation.controller;

import com.example.myannotation.model.MyUser;
import com.example.myannotation.model.Student;
import com.example.myannotation.util.ChangValue;
import org.springframework.web.bind.annotation.*;


/**
 * @author tianzhuang
 * @version 1.0
 * @date 2022/1/7 22:24
 */
@RestController
@RequestMapping("test")
public class MyAnnotationController {

    @PostMapping("getName")
    public String test(@RequestBody MyUser user) {
        try {
            ChangValue.getValByClass(user);
            return "test"+ user.toString();
        } catch (Exception e) {
            return "error";
        }
    }


    @PostMapping("getName2")
    public String test(@RequestBody Student student) {
        try {
            ChangValue.getValByClass(student);
            return "test"+ student.toString();
        } catch (Exception e) {
            return "error";
        }
    }
}
